import {BaseModel} from "../BaseModel";

export class Machine extends BaseModel{

    constructor(){
        super();
        this.symbolName = "Machine";
        this.tableName = "t_machine";
        this.id = -1;//主键id
        this.hostName = '';//主机名称
        this.type = '';//操作系统名
        this.platform = '';//编译时的操作系统名
        this.arch = '';//操作系统 CPU 架构，可能的值有 "x64"、"arm" 和 "ia32"
        this.totalmem = '';//系统内存总量，单位为字节
        this.freemem = '';//操作系统空闲内存量，单位是字节
        this.cpus = '';//包含所安装的每个 CPU/内核的信息：型号、速度
    }

    dbMapper(){
        return {
            id: 'id',
            hostName: 'host_name',
            type: 'type',
            platform: 'platform',
            arch: 'arch',
            totalmem: 'totalmem',
            freemem: 'freemem',
            cpus: 'cpus'
        }
    }

    /**
     * 输出转换
     * @param obj
     * @returns {Book}
     */
    mappingModel(obj){
        let machine = new Machine();
        machine.id = obj.id ? obj.id : -1
        machine.hostName = obj.host_name ? obj.host_name : ''
        machine.type = obj.type ? obj.type : ''
        machine.platform = obj.platform ? obj.platform : ''
        machine.arch = obj.arch ? obj.arch : ''
        machine.totalmem = obj.totalmem ? obj.totalmem : ''
        machine.freemem = obj.freemem ? obj.freemem : ''
        machine.cpus = obj.cpus ? obj.cpus : ''
        return machine;
    }
}
